
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>6.乐观锁与悲观锁.md · 计算机 ,java , 大数据 基础知识体系</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="hzh">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2.CAS与atomic类.html" />
    
    
    <link rel="prev" href="../basic/2.ThreadLocal.html" />
    

    
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">操作系统</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../操作系统/1.基本概述.html">
            
                <a href="../../操作系统/1.基本概述.html">
            
                    
                    1.操作系统基本概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../操作系统/2.进程管理之进程与线程.html">
            
                <a href="../../操作系统/2.进程管理之进程与线程.html">
            
                    
                    2.进程管理之进程与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../操作系统/3.进程管理之处理机调度.html">
            
                <a href="../../操作系统/3.进程管理之处理机调度.html">
            
                    
                    3.进程管理之处理机调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../操作系统/4.进程管理之进程同步.html">
            
                <a href="../../操作系统/4.进程管理之进程同步.html">
            
                    
                    4.进程管理之进程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../操作系统/5.内存管理之基本概念.html">
            
                <a href="../../操作系统/5.内存管理之基本概念.html">
            
                    
                    5.内存管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../../操作系统/6.内存管理之虚拟内存.html">
            
                <a href="../../操作系统/6.内存管理之虚拟内存.html">
            
                    
                    6.内存管理之虚拟内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../../操作系统/7.IO设备管理之基本概念.html">
            
                <a href="../../操作系统/7.IO设备管理之基本概念.html">
            
                    
                    7.IO设备管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../../操作系统/8.面试题总结一.html">
            
                <a href="../../操作系统/8.面试题总结一.html">
            
                    
                    8.面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">计算机网络篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../计算机网络/1.计算机网络入门基础概念.html">
            
                <a href="../../计算机网络/1.计算机网络入门基础概念.html">
            
                    
                    1.计算机网络入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../../计算机网络/2.计算机网络通信基础.html">
            
                <a href="../../计算机网络/2.计算机网络通信基础.html">
            
                    
                    2.计算机网络通信入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../../计算机网络/3.数据链路层.html">
            
                <a href="../../计算机网络/3.数据链路层.html">
            
                    
                    3.数据链路层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../../计算机网络/4.网络层1.html">
            
                <a href="../../计算机网络/4.网络层1.html">
            
                    
                    4.网络层(一)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../../计算机网络/5.网络层2.html">
            
                <a href="../../计算机网络/5.网络层2.html">
            
                    
                    5.网络层(二)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../../计算机网络/6.传输层.html">
            
                <a href="../../计算机网络/6.传输层.html">
            
                    
                    6.传输层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../../计算机网络/7.应用层.html">
            
                <a href="../../计算机网络/7.应用层.html">
            
                    
                    7.应用层(⭐)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../../计算机网络/10.HTTP相关协议.html">
            
                <a href="../../计算机网络/10.HTTP相关协议.html">
            
                    
                    8.HTTP相关及发展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" >
            
                <span>
            
                    
                    9.websocket
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../../计算机网络/9.面试题二.html">
            
                <a href="../../计算机网络/9.面试题二.html">
            
                    
                    面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">数据结构篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../数据结构/1.图论.html">
            
                <a href="../../数据结构/1.图论.html">
            
                    
                    1.图论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../../数据结构/2.图论例题.html">
            
                <a href="../../数据结构/2.图论例题.html">
            
                    
                    2.图论例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../../数据结构/3.散列表.html">
            
                <a href="../../数据结构/3.散列表.html">
            
                    
                    3.散列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../../数据结构/4.排序算法.html">
            
                <a href="../../数据结构/4.排序算法.html">
            
                    
                    4.排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../../数据结构/5.排序列题.html">
            
                <a href="../../数据结构/5.排序列题.html">
            
                    
                    5.排序算法例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../../数据结构/6.树论.html">
            
                <a href="../../数据结构/6.树论.html">
            
                    
                    6.树论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../../数据结构/7.树论例题.html">
            
                <a href="../../数据结构/7.树论例题.html">
            
                    
                    7.树论例题.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../../数据结构/9.模板.html">
            
                <a href="../../数据结构/9.模板.html">
            
                    
                    数据结构模板
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">算法篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../算法/leetCode周赛题解.html">
            
                <a href="../../算法/leetCode周赛题解.html">
            
                    
                    leetCode周赛记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../../算法/1.时间复杂度.html">
            
                <a href="../../算法/1.时间复杂度.html">
            
                    
                    1.时间复杂度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../../算法/2.深度优先搜索.html">
            
                <a href="../../算法/2.深度优先搜索.html">
            
                    
                    2.深度优先搜索算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../算法/2.深度优先搜索题目集.html">
            
                <a href="../../算法/2.深度优先搜索题目集.html">
            
                    
                    2.深搜题目集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../算法/3.广度优先搜索.html">
            
                <a href="../../算法/3.广度优先搜索.html">
            
                    
                    3.广度优先搜索算法
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JVM篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../jvm/1.jvm内存结构.html">
            
                <a href="../../jvm/1.jvm内存结构.html">
            
                    
                    1.jvm内存结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../jvm/2.HotSpot虚拟机对象探秘.html">
            
                <a href="../../jvm/2.HotSpot虚拟机对象探秘.html">
            
                    
                    2.HotSpot虚拟机对象探秘.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../jvm/3.对象存亡与垃圾收集算法.html">
            
                <a href="../../jvm/3.对象存亡与垃圾收集算法.html">
            
                    
                    3.对象存亡与垃圾收集算法.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                <a href="../../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                    
                    4.HotSpot的算法细节与垃圾收集器.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../../jvm/5.内存分配与回收策略.html">
            
                <a href="../../jvm/5.内存分配与回收策略.html">
            
                    
                    5.内存分配与回收策略.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../../jvm/6.类文件结构.html">
            
                <a href="../../jvm/6.类文件结构.html">
            
                    
                    6.类文件结构.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../../jvm/7.类加载机制.html">
            
                <a href="../../jvm/7.类加载机制.html">
            
                    
                    7.类加载机制.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../../jvm/8.jvm逃逸分析.html">
            
                <a href="../../jvm/8.jvm逃逸分析.html">
            
                    
                    8.逃逸分析技术
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">多线程篇</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../basic/0.多线程路线图.html">
            
                <a href="../basic/0.多线程路线图.html">
            
                    
                    1.多线程学习路线图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../basic/0.java内存模型与线程.html">
            
                <a href="../basic/0.java内存模型与线程.html">
            
                    
                    2.java内存模型与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../3.并行程序基础.html">
            
                <a href="../3.并行程序基础.html">
            
                    
                    2.并行程序基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../basic/0.jhappenBefore与jvm指令重排.html">
            
                <a href="../basic/0.jhappenBefore与jvm指令重排.html">
            
                    
                    3.happenBefore与jvm指令重排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../basic/1.synchronized与volatile.html">
            
                <a href="../basic/1.synchronized与volatile.html">
            
                    
                    4.synchronized与volatile.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="../basic/2.ThreadLocal.html">
            
                <a href="../basic/2.ThreadLocal.html">
            
                    
                    5.ThreadLocal.md
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="6.7" data-path="1.乐观锁与悲观锁.html">
            
                <a href="1.乐观锁与悲观锁.html">
            
                    
                    6.乐观锁与悲观锁.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="2.CAS与atomic类.html">
            
                <a href="2.CAS与atomic类.html">
            
                    
                    7.CAS与atomic类.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="../aqs/1.AQS.html">
            
                <a href="../aqs/1.AQS.html">
            
                    
                    8.AQS.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="../aqs/2.基于AQS的并发工具.html">
            
                <a href="../aqs/2.基于AQS的并发工具.html">
            
                    
                    9.基于AQS的并发工具.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="../blockingQueue/1.阻塞队列.html">
            
                <a href="../blockingQueue/1.阻塞队列.html">
            
                    
                    10.阻塞队列.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="../pond/1.线程池与底层原理.html">
            
                <a href="../pond/1.线程池与底层原理.html">
            
                    
                    11.线程池与底层原理.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="../10面试题一.html">
            
                <a href="../10面试题一.html">
            
                    
                    12.面试题一
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="../10面试题二.html">
            
                <a href="../10面试题二.html">
            
                    
                    13.面试题二.md
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">java集合篇</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../../basic/collection/1.java集合.html">
            
                <a href="../../basic/collection/1.java集合.html">
            
                    
                    1.集合架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../../basic/collection/2.HashMap源码分析.html">
            
                <a href="../../basic/collection/2.HashMap源码分析.html">
            
                    
                    2.hashMap底层原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../../basic/collection/3.ConcurrentHashMap分析.html">
            
                <a href="../../basic/collection/3.ConcurrentHashMap分析.html">
            
                    
                    3.ConcurrentHashMap分析
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">设计模式篇</li>
        
        
    
        <li class="chapter " data-level="8.1" >
            
                <span>
            
                    
                    1.创造型模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="../../设计模式/factory/三种工厂模式介绍.html">
            
                <a href="../../设计模式/factory/三种工厂模式介绍.html">
            
                    
                    三种工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="../../设计模式/factory/实战工厂模式.html">
            
                <a href="../../设计模式/factory/实战工厂模式.html">
            
                    
                    实战工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="../../设计模式/factory/实战抽象工厂模式.html">
            
                <a href="../../设计模式/factory/实战抽象工厂模式.html">
            
                    
                    实战抽象工厂模式
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">mysql篇</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../../数据库/mysql/1.b树b+树的底层原理.html">
            
                <a href="../../数据库/mysql/1.b树b+树的底层原理.html">
            
                    
                    1.mysql索引基础之b树与b+树⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../../数据库/mysql/2.mysql索引.html">
            
                <a href="../../数据库/mysql/2.mysql索引.html">
            
                    
                    2.mysql索引及优化⭐⭐⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../../数据库/mysql/3.mysql存储引擎.html">
            
                <a href="../../数据库/mysql/3.mysql存储引擎.html">
            
                    
                    3.mysql存储引擎.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="../../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                <a href="../../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                    
                    4.多版本并发控制之mvcc原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="../../数据库/mysql/4.mysql事务.html">
            
                <a href="../../数据库/mysql/4.mysql事务.html">
            
                    
                    5.mysql事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.6" data-path="../../数据库/mysql/5.mysql锁机制.html">
            
                <a href="../../数据库/mysql/5.mysql锁机制.html">
            
                    
                    6.mysql的锁机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.7" data-path="../../数据库/mysql/6.mysql面试题一.html">
            
                <a href="../../数据库/mysql/6.mysql面试题一.html">
            
                    
                    7.mysql面试题一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高并发中间件篇</li>
        
        
    

    
        
        <li class="header">架构理论篇</li>
        
        
    
        <li class="chapter " data-level="11.1" data-path="../../架构/0.架构演进.html">
            
                <a href="../../架构/0.架构演进.html">
            
                    
                    1.架构演进
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="11.2" data-path="../../架构/0.微服务架构与soa架构.html">
            
                <a href="../../架构/0.微服务架构与soa架构.html">
            
                    
                    2.微服务架构与soa架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高可用系统篇</li>
        
        
    
        <li class="chapter " data-level="12.1" data-path="../../高可用架构/1.限流.html">
            
                <a href="../../高可用架构/1.限流.html">
            
                    
                    1.系统限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="../../高可用系统/2.服务熔断.html">
            
                <a href="../../高可用系统/2.服务熔断.html">
            
                    
                    2.服务熔断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.3" data-path="../../高可用系统/3.服务降级.html">
            
                <a href="../../高可用系统/3.服务降级.html">
            
                    
                    3.服务降级
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">spring-cloud 微服务篇</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >6.乐观锁与悲观锁.md</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;"><b></b>1.&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;</a></li></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;"><a name="1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;" class="anchor-navigation-ex-anchor" href="#1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;" class="plugin-anchor" href="#1&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a>1.&#x4F55;&#x8C13;&#x60B2;&#x89C2;&#x9501;&#x4E0E;&#x4E50;&#x89C2;&#x9501;</h2>
<blockquote>
<p>&#x4E50;&#x89C2;&#x9501;&#x5BF9;&#x5E94;&#x4E8E;&#x751F;&#x6D3B;&#x4E2D;&#x4E50;&#x89C2;&#x7684;&#x4EBA;&#x603B;&#x662F;&#x60F3;&#x7740;&#x4E8B;&#x60C5;&#x5F80;&#x597D;&#x7684;&#x65B9;&#x5411;&#x53D1;&#x5C55;&#xFF0C;&#x60B2;&#x89C2;&#x9501;&#x5BF9;&#x5E94;&#x4E8E;&#x751F;&#x6D3B;&#x4E2D;&#x60B2;&#x89C2;&#x7684;&#x4EBA;&#x603B;&#x662F;&#x60F3;&#x7740;&#x4E8B;&#x60C5;&#x5F80;&#x574F;&#x7684;&#x65B9;&#x5411;&#x53D1;&#x5C55;&#x3002;&#x8FD9;&#x4E24;&#x79CD;&#x4EBA;&#x5404;&#x6709;&#x4F18;&#x7F3A;&#x70B9;&#xFF0C;&#x4E0D;&#x80FD;&#x4E0D;&#x4EE5;&#x573A;&#x666F;&#x800C;&#x5B9A;&#x8BF4;&#x4E00;&#x79CD;&#x4EBA;&#x597D;&#x4E8E;&#x53E6;&#x5916;&#x4E00;&#x79CD;&#x4EBA;&#x3002;</p>
</blockquote>
<h4 id="&#x60B2;&#x89C2;&#x9501;"><a name="&#x60B2;&#x89C2;&#x9501;" class="anchor-navigation-ex-anchor" href="#&#x60B2;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x60B2;&#x89C2;&#x9501;" class="plugin-anchor" href="#&#x60B2;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x60B2;&#x89C2;&#x9501;</h4>
<p>&#x603B;&#x662F;&#x5047;&#x8BBE;&#x6700;&#x574F;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6BCF;&#x6B21;&#x53BB;&#x62FF;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x8BA4;&#x4E3A;&#x522B;&#x4EBA;&#x4F1A;&#x4FEE;&#x6539;&#xFF0C;&#x6240;&#x4EE5;&#x6BCF;&#x6B21;&#x5728;&#x62FF;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x4F1A;&#x4E0A;&#x9501;&#xFF0C;&#x8FD9;&#x6837;&#x522B;&#x4EBA;&#x60F3;&#x62FF;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#x5C31;&#x4F1A;&#x963B;&#x585E;&#x76F4;&#x5230;&#x5B83;&#x62FF;&#x5230;&#x9501;&#xFF08;<strong>&#x5171;&#x4EAB;&#x8D44;&#x6E90;&#x6BCF;&#x6B21;&#x53EA;&#x7ED9;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x4F7F;&#x7528;&#xFF0C;&#x5176;&#x5B83;&#x7EBF;&#x7A0B;&#x963B;&#x585E;&#xFF0C;&#x7528;&#x5B8C;&#x540E;&#x518D;&#x628A;&#x8D44;&#x6E90;&#x8F6C;&#x8BA9;&#x7ED9;&#x5176;&#x5B83;&#x7EBF;&#x7A0B;</strong>&#xFF09;&#x3002;&#x4F20;&#x7EDF;&#x7684;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x91CC;&#x8FB9;&#x5C31;&#x7528;&#x5230;&#x4E86;&#x5F88;&#x591A;&#x8FD9;&#x79CD;&#x9501;&#x673A;&#x5236;&#xFF0C;&#x6BD4;&#x5982;&#x884C;&#x9501;&#xFF0C;&#x8868;&#x9501;&#x7B49;&#xFF0C;&#x8BFB;&#x9501;&#xFF0C;&#x5199;&#x9501;&#x7B49;&#xFF0C;&#x90FD;&#x662F;&#x5728;&#x505A;&#x64CD;&#x4F5C;&#x4E4B;&#x524D;&#x5148;&#x4E0A;&#x9501;&#x3002;Java&#x4E2D;<code>synchronized</code>&#x548C;<code>ReentrantLock</code>&#x7B49;&#x72EC;&#x5360;&#x9501;&#x5C31;&#x662F;&#x60B2;&#x89C2;&#x9501;&#x601D;&#x60F3;&#x7684;&#x5B9E;&#x73B0;&#x3002;</p>
<h4 id="&#x4E50;&#x89C2;&#x9501;"><a name="&#x4E50;&#x89C2;&#x9501;" class="anchor-navigation-ex-anchor" href="#&#x4E50;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E50;&#x89C2;&#x9501;" class="plugin-anchor" href="#&#x4E50;&#x89C2;&#x9501;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E50;&#x89C2;&#x9501;</h4>
<p>&#x603B;&#x662F;&#x5047;&#x8BBE;&#x6700;&#x597D;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6BCF;&#x6B21;&#x53BB;&#x62FF;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x8BA4;&#x4E3A;&#x522B;&#x4EBA;&#x4E0D;&#x4F1A;&#x4FEE;&#x6539;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x4F1A;&#x4E0A;&#x9501;&#xFF0C;&#x4F46;&#x662F;&#x5728;&#x66F4;&#x65B0;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x5224;&#x65AD;&#x4E00;&#x4E0B;&#x5728;&#x6B64;&#x671F;&#x95F4;&#x522B;&#x4EBA;&#x6709;&#x6CA1;&#x6709;&#x53BB;&#x66F4;&#x65B0;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;&#x548C;CAS&#x7B97;&#x6CD5;&#x5B9E;&#x73B0;&#x3002;<strong>&#x4E50;&#x89C2;&#x9501;&#x9002;&#x7528;&#x4E8E;&#x591A;&#x8BFB;&#x7684;&#x5E94;&#x7528;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x63D0;&#x9AD8;&#x541E;&#x5410;&#x91CF;</strong>&#xFF0C;&#x50CF;&#x6570;&#x636E;&#x5E93;&#x63D0;&#x4F9B;&#x7684;&#x7C7B;&#x4F3C;&#x4E8E;<strong>write_condition&#x673A;&#x5236;</strong>&#xFF0C;&#x5176;&#x5B9E;&#x90FD;&#x662F;&#x63D0;&#x4F9B;&#x7684;&#x4E50;&#x89C2;&#x9501;&#x3002;&#x5728;Java&#x4E2D;<code>java.util.concurrent.atomic</code>&#x5305;&#x4E0B;&#x9762;&#x7684;&#x539F;&#x5B50;&#x53D8;&#x91CF;&#x7C7B;&#x5C31;&#x662F;&#x4F7F;&#x7528;&#x4E86;&#x4E50;&#x89C2;&#x9501;&#x7684;&#x4E00;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;<strong>CAS</strong>&#x5B9E;&#x73B0;&#x7684;&#x3002;</p>
<h4 id="&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;"><a name="&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;" class="anchor-navigation-ex-anchor" href="#&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;" class="plugin-anchor" href="#&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;</h4>
<p>&#x4ECE;&#x4E0A;&#x9762;&#x5BF9;&#x4E24;&#x79CD;&#x9501;&#x7684;&#x4ECB;&#x7ECD;&#xFF0C;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x4E24;&#x79CD;&#x9501;&#x5404;&#x6709;&#x4F18;&#x7F3A;&#x70B9;&#xFF0C;&#x4E0D;&#x53EF;&#x8BA4;&#x4E3A;&#x4E00;&#x79CD;&#x597D;&#x4E8E;&#x53E6;&#x4E00;&#x79CD;&#xFF0C;&#x50CF;<strong>&#x4E50;&#x89C2;&#x9501;&#x9002;&#x7528;&#x4E8E;&#x5199;&#x6BD4;&#x8F83;&#x5C11;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF08;&#x591A;&#x8BFB;&#x573A;&#x666F;&#xFF09;</strong>&#xFF0C;&#x5373;&#x51B2;&#x7A81;&#x771F;&#x7684;&#x5F88;&#x5C11;&#x53D1;&#x751F;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x7701;&#x53BB;&#x4E86;&#x9501;&#x7684;&#x5F00;&#x9500;&#xFF0C;&#x52A0;&#x5927;&#x4E86;&#x7CFB;&#x7EDF;&#x7684;&#x6574;&#x4E2A;&#x541E;&#x5410;&#x91CF;&#x3002;&#x4F46;&#x5982;&#x679C;&#x662F;&#x591A;&#x5199;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x4E00;&#x822C;&#x4F1A;&#x7ECF;&#x5E38;&#x4EA7;&#x751F;&#x51B2;&#x7A81;&#xFF0C;&#x8FD9;&#x5C31;&#x4F1A;&#x5BFC;&#x81F4;&#x4E0A;&#x5C42;&#x5E94;&#x7528;&#x4F1A;&#x4E0D;&#x65AD;&#x7684;&#x8FDB;&#x884C;retry&#xFF0C;&#x8FD9;&#x6837;&#x53CD;&#x5012;&#x662F;&#x964D;&#x4F4E;&#x4E86;&#x6027;&#x80FD;&#xFF0C;&#x6240;&#x4EE5;<strong>&#x4E00;&#x822C;&#x591A;&#x5199;&#x7684;&#x573A;&#x666F;&#x4E0B;&#x7528;&#x60B2;&#x89C2;&#x9501;&#x5C31;&#x6BD4;&#x8F83;&#x5408;&#x9002;&#x3002;</strong></p>
<h4 id="&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><a name="&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E50;&#x89C2;&#x9501;&#x5E38;&#x89C1;&#x7684;&#x4E24;&#x79CD;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;</h4>
<blockquote>
<p><strong>&#x4E50;&#x89C2;&#x9501;&#x4E00;&#x822C;&#x4F1A;&#x4F7F;&#x7528;&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;&#x6216;CAS&#x7B97;&#x6CD5;&#x5B9E;&#x73B0;&#x3002;</strong></p>
</blockquote>
<h5 id="1-&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;"><a name="1-&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;" class="anchor-navigation-ex-anchor" href="#1-&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1-&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;" class="plugin-anchor" href="#1-&#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x7248;&#x672C;&#x53F7;&#x673A;&#x5236;</h5>
<p>&#x4E00;&#x822C;&#x662F;&#x5728;&#x6570;&#x636E;&#x8868;&#x4E2D;&#x52A0;&#x4E0A;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x7248;&#x672C;&#x53F7;version&#x5B57;&#x6BB5;&#xFF0C;&#x8868;&#x793A;&#x6570;&#x636E;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x6B21;&#x6570;&#xFF0C;&#x5F53;&#x6570;&#x636E;&#x88AB;&#x4FEE;&#x6539;&#x65F6;&#xFF0C;version&#x503C;&#x4F1A;&#x52A0;&#x4E00;&#x3002;&#x5F53;&#x7EBF;&#x7A0B;A&#x8981;&#x66F4;&#x65B0;&#x6570;&#x636E;&#x503C;&#x65F6;&#xFF0C;&#x5728;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x7684;&#x540C;&#x65F6;&#x4E5F;&#x4F1A;&#x8BFB;&#x53D6;version&#x503C;&#xFF0C;&#x5728;&#x63D0;&#x4EA4;&#x66F4;&#x65B0;&#x65F6;&#xFF0C;&#x82E5;&#x521A;&#x624D;&#x8BFB;&#x53D6;&#x5230;&#x7684;version&#x503C;&#x4E3A;&#x5F53;&#x524D;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x7684;version&#x503C;&#x76F8;&#x7B49;&#x65F6;&#x624D;&#x66F4;&#x65B0;&#xFF0C;&#x5426;&#x5219;&#x91CD;&#x8BD5;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;&#xFF0C;&#x76F4;&#x5230;&#x66F4;&#x65B0;&#x6210;&#x529F;&#x3002;</p>
<p><strong>&#x4E3E;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</strong>
&#x5047;&#x8BBE;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x5E10;&#x6237;&#x4FE1;&#x606F;&#x8868;&#x4E2D;&#x6709;&#x4E00;&#x4E2A; version &#x5B57;&#x6BB5;&#xFF0C;&#x5F53;&#x524D;&#x503C;&#x4E3A; 1 &#xFF1B;&#x800C;&#x5F53;&#x524D;&#x5E10;&#x6237;&#x4F59;&#x989D;&#x5B57;&#x6BB5;&#xFF08; balance &#xFF09;&#x4E3A; $100 &#x3002;</p>
<ol>
<li>&#x64CD;&#x4F5C;&#x5458; A &#x6B64;&#x65F6;&#x5C06;&#x5176;&#x8BFB;&#x51FA;&#xFF08; version=1 &#xFF09;&#xFF0C;&#x5E76;&#x4ECE;&#x5176;&#x5E10;&#x6237;&#x4F59;&#x989D;&#x4E2D;&#x6263;&#x9664; $50&#xFF08; $100-$50 &#xFF09;&#x3002;</li>
<li>&#x5728;&#x64CD;&#x4F5C;&#x5458; A &#x64CD;&#x4F5C;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x64CD;&#x4F5C;&#x5458;B &#x4E5F;&#x8BFB;&#x5165;&#x6B64;&#x7528;&#x6237;&#x4FE1;&#x606F;&#xFF08; version=1 &#xFF09;&#xFF0C;&#x5E76;&#x4ECE;&#x5176;&#x5E10;&#x6237;&#x4F59;&#x989D;&#x4E2D;&#x6263;&#x9664; $20 &#xFF08; $100-$20 &#xFF09;&#x3002;</li>
<li>&#x64CD;&#x4F5C;&#x5458; A &#x5B8C;&#x6210;&#x4E86;&#x4FEE;&#x6539;&#x5DE5;&#x4F5C;&#xFF0C;&#x5C06;&#x6570;&#x636E;&#x7248;&#x672C;&#x53F7;&#x52A0;&#x4E00;&#xFF08; version=2 &#xFF09;&#xFF0C;&#x8FDE;&#x540C;&#x5E10;&#x6237;&#x6263;&#x9664;&#x540E;&#x4F59;&#x989D;&#xFF08; balance=$50 &#xFF09;&#xFF0C;&#x63D0;&#x4EA4;&#x81F3;&#x6570;&#x636E;&#x5E93;&#x66F4;&#x65B0;&#xFF0C;&#x6B64;&#x65F6;&#x7531;&#x4E8E;&#x63D0;&#x4EA4;&#x6570;&#x636E;&#x7248;&#x672C;&#x5927;&#x4E8E;&#x6570;&#x636E;&#x5E93;&#x8BB0;&#x5F55;&#x5F53;&#x524D;&#x7248;&#x672C;&#xFF0C;&#x6570;&#x636E;&#x88AB;&#x66F4;&#x65B0;&#xFF0C;&#x6570;&#x636E;&#x5E93;&#x8BB0;&#x5F55; version &#x66F4;&#x65B0;&#x4E3A; 2 &#x3002;</li>
<li>&#x64CD;&#x4F5C;&#x5458; B &#x5B8C;&#x6210;&#x4E86;&#x64CD;&#x4F5C;&#xFF0C;&#x4E5F;&#x5C06;&#x7248;&#x672C;&#x53F7;&#x52A0;&#x4E00;&#xFF08; version=2 &#xFF09;&#x8BD5;&#x56FE;&#x5411;&#x6570;&#x636E;&#x5E93;&#x63D0;&#x4EA4;&#x6570;&#x636E;&#xFF08; balance=$80 &#xFF09;&#xFF0C;&#x4F46;&#x6B64;&#x65F6;&#x6BD4;&#x5BF9;&#x6570;&#x636E;&#x5E93;&#x8BB0;&#x5F55;&#x7248;&#x672C;&#x65F6;&#x53D1;&#x73B0;&#xFF0C;&#x64CD;&#x4F5C;&#x5458; B &#x63D0;&#x4EA4;&#x7684;&#x6570;&#x636E;&#x7248;&#x672C;&#x53F7;&#x4E3A; 2 &#xFF0C;&#x6570;&#x636E;&#x5E93;&#x8BB0;&#x5F55;&#x5F53;&#x524D;&#x7248;&#x672C;&#x4E5F;&#x4E3A; 2 &#xFF0C;&#x4E0D;&#x6EE1;&#x8DB3; &#x201C; &#x63D0;&#x4EA4;&#x7248;&#x672C;&#x5FC5;&#x987B;&#x5927;&#x4E8E;&#x8BB0;&#x5F55;&#x5F53;&#x524D;&#x7248;&#x672C;&#x624D;&#x80FD;&#x6267;&#x884C;&#x66F4;&#x65B0; &#x201C; &#x7684;&#x4E50;&#x89C2;&#x9501;&#x7B56;&#x7565;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x64CD;&#x4F5C;&#x5458; B &#x7684;&#x63D0;&#x4EA4;&#x88AB;&#x9A73;&#x56DE;&#x3002;</li>
</ol>
<p>&#x8FD9;&#x6837;&#xFF0C;&#x5C31;&#x907F;&#x514D;&#x4E86;&#x64CD;&#x4F5C;&#x5458; B &#x7528;&#x57FA;&#x4E8E; version=1 &#x7684;&#x65E7;&#x6570;&#x636E;&#x4FEE;&#x6539;&#x7684;&#x7ED3;&#x679C;&#x8986;&#x76D6;&#x64CD;&#x4F5C;&#x5458;A &#x7684;&#x64CD;&#x4F5C;&#x7ED3;&#x679C;&#x7684;&#x53EF;&#x80FD;&#x3002;</p>
<h5 id="2-cas&#x7B97;&#x6CD5;"><a name="2-cas&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#2-cas&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2-cas&#x7B97;&#x6CD5;" class="plugin-anchor" href="#2-cas&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>2. CAS&#x7B97;&#x6CD5;</h5>
<p>&#x5373;<strong>compare and swap&#xFF08;&#x6BD4;&#x8F83;&#x4E0E;&#x4EA4;&#x6362;&#xFF09;</strong>&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x6709;&#x540D;&#x7684;<strong>&#x65E0;&#x9501;&#x7B97;&#x6CD5;</strong>&#x3002;&#x65E0;&#x9501;&#x7F16;&#x7A0B;&#xFF0C;&#x5373;&#x4E0D;&#x4F7F;&#x7528;&#x9501;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x5B9E;&#x73B0;&#x591A;&#x7EBF;&#x7A0B;&#x4E4B;&#x95F4;&#x7684;&#x53D8;&#x91CF;&#x540C;&#x6B65;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5728;&#x6CA1;&#x6709;&#x7EBF;&#x7A0B;&#x88AB;&#x963B;&#x585E;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x5B9E;&#x73B0;&#x53D8;&#x91CF;&#x7684;&#x540C;&#x6B65;&#xFF0C;&#x6240;&#x4EE5;&#x4E5F;&#x53EB;&#x975E;&#x963B;&#x585E;&#x540C;&#x6B65;&#xFF08;Non-blocking Synchronization&#xFF09;&#x3002;<strong>CAS&#x7B97;&#x6CD5;</strong>&#x6D89;&#x53CA;&#x5230;&#x4E09;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;</p>
<ul>
<li>&#x9700;&#x8981;&#x8BFB;&#x5199;&#x7684;&#x5185;&#x5B58;&#x503C; V </li>
<li>&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#x7684;&#x503C; A </li>
<li>&#x62DF;&#x5199;&#x5165;&#x7684;&#x65B0;&#x503C; B</li>
</ul>
<p>&#x5F53;&#x4E14;&#x4EC5;&#x5F53; V &#x7684;&#x503C;&#x7B49;&#x4E8E; A&#x65F6;&#xFF0C;CAS&#x901A;&#x8FC7;&#x539F;&#x5B50;&#x65B9;&#x5F0F;&#x7528;&#x65B0;&#x503C;B&#x6765;&#x66F4;&#x65B0;V&#x7684;&#x503C;&#xFF0C;&#x5426;&#x5219;&#x4E0D;&#x4F1A;&#x6267;&#x884C;&#x4EFB;&#x4F55;&#x64CD;&#x4F5C;&#xFF08;&#x6BD4;&#x8F83;&#x548C;&#x66FF;&#x6362;&#x662F;&#x4E00;&#x4E2A;&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#xFF09;&#x3002;&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#x662F;&#x4E00;&#x4E2A;<strong>&#x81EA;&#x65CB;&#x64CD;&#x4F5C;</strong>&#xFF0C;&#x5373;<strong>&#x4E0D;&#x65AD;&#x7684;&#x91CD;&#x8BD5;</strong>&#x3002;</p>

<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../basic/2.ThreadLocal.html" class="navigation navigation-prev " aria-label="Previous page: 5.ThreadLocal.md">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="2.CAS与atomic类.html" class="navigation navigation-next " aria-label="Next page: 7.CAS与atomic类.md">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"6.乐观锁与悲观锁.md","level":"6.7","depth":1,"next":{"title":"7.CAS与atomic类.md","level":"6.8","depth":1,"path":"多线程/cas/2.CAS与atomic类.md","ref":"多线程/cas/2.CAS与atomic类.md","articles":[]},"previous":{"title":"5.ThreadLocal.md","level":"6.6","depth":1,"path":"多线程/basic/2.ThreadLocal.md","ref":"多线程/basic/2.ThreadLocal.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","sharing-plus","anchor-navigation-ex","favicon","expandable-chapters","toggle-chapters","back-to-top-button","code","-lunr","-search","search-pro","pageview-count","popup","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{},"expandable-chapters":{}},"theme":"default","author":"hzh","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"计算机 ,java , 大数据 基础知识体系","language":"zh-hans","gitbook":"3.2.3"},"file":{"path":"多线程/cas/1.乐观锁与悲观锁.md","mtime":"2020-12-19T09:03:20.796Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-30T11:12:56.611Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

